import Row from "./basics/basics/Row";
import  Block from './basics/Block.js'

export default class Transcode{
    constructor(wordSign,field,ac,pack){
        this.commm=[];//执行命令
        this.teml=[];//模板
        this.data=[];//数据
        this.res=[];

    }

    /**
     * 获取执行命令
     */
    /**
     * 找到模板
     */
    /**
     * 找到需要替换的数据
     */
    /**
     * 找到替换规则
     */
    /**
     * 替换
     */

    /**
     * 生成数据 结构 名词 动词 主词
     */
    createData(wordSign ){
        let field='27' ; //转换
        let act='27' ; //代码field,act,
        let verb='11' ;// 动词
        let noun='11' ;// 名词
        let structure='11' ;// 结构

        let comms=[];
        let comm=[];
        let zhuyu='';
        let caozuo='';
        for(let i=0;i<wordSign.length;i++){
            if(this.isComm(comm)){
                comms.push(comm)
                comm =new Array();
            }

            let words=wordSign[i];
            if(comm[3]){
                zhuyu=comm[3]
            }else {
                zhuyu=field
            }
            if(comm[2]){
                caozuo=comm[2]
            }else {
                caozuo=act
            }


            let isVerb=this.isSign(words,zhuyu,caozuo,verb);  //动词
            let isNoun=this.isSign(words,zhuyu,caozuo,noun); //名词
            let isStructure =this.isSign(words,zhuyu,caozuo,structure); //结构

            if(isVerb &&!comm[3]){ //动词 创建一个动作
                comm[2]=words
                continue
            }

            if(isNoun||!comm[3]){
                let wordsB=wordSign[i+1];
                let isNounB=this.isSign(wordsB,field,act,verb); //名词
                let wordsIds=words;
                while (isNounB||!comm[3]) {
                    wordsIds=this.findWordsId(wordsIds,wordsB);  //合并名词
                     i++;
                      wordsB=wordSign[i+1];
                      isNounB=this.isSign(wordsB,field,act,verb); //名词
                }
                if(isNounB){ //检查是不是主语
                    comm[3]=wordsIds
                }else{
                    comm[1]=wordsIds
                }
                continue;
            }


            if(isStructure){
                comm[0]=wordsIds
                continue;
            }
        }

        for(let i=0;i<comms.length;i++){
            if(comms[i].isStructure){ //对代码中的结构进行处理

            }

        }
        return tempData;
    }


    /**
     *
     */
    findWordsId(){
        return id;
    }
    /**
     * 检查是否标记
     * @param wordSign
     */
    isSign(wordSign,field,act,idea){
        /**
         *  数字  digit
         *  符号 other
         *  单位 unit
         *
         * @type {Array}
         */
        for(let l=0 ;l<wordSign.list.length;l++) {
            let row =wordSign.list[l];
            let res=[];
            if(row.isValue(1,field)) res.push(1);
            if(row.isValue(2,act)) res.push(1)
            if(row.isValue(4,idea)) res.push(1)
            if (res.length==3) {
                if(row.isValue(3,'1')) return true
            }
        }

        return false;
    }

    /**
     * 获取模板
     * @returns {Array}
     */
    findTml(){
        return new Block();
    }
}

